package dao.imp;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import util.DBUtil;
import dao.AreaDao;

public class AreaDaoImp implements AreaDao {

	@Override
	public List<String> findByFuzzy(String s) {
		String sql = "select area from areas where area like ?";
		PreparedStatement pst = null;
		ResultSet rs = null;
		List<String> list = new ArrayList<>();
		Connection con =null;
		String area;
		try {
		    con = DBUtil.createConnection();
			pst=con.prepareStatement(sql);
			pst.setString(1, "%"+s+"%");
			rs = pst.executeQuery();
			while(rs.next()){
				area = rs.getString("area");
				list.add(area);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			DBUtil.close(con,pst,rs);
		}
		return list;
	}

}
